import {IWxJsSDKCommonParam} from "../IWxJsSDKCommonParam";

export default interface CategoryImage {

    chooseImage(param: IWxJsSDKChooseImageParam): void;

    previewImage(param: { current: string; urls: string[] }): void;

    uploadImage(param: IWxJsSDKUploadImageParam): void;

    downloadImage(param: IWxJsSDKDownloadImageParam): void;

    getLocalImgData(param: IWxJsSDKGetLocalImgDataParam): void;

}

export interface IWxJsSDKGetLocalImgDataParam extends IWxJsSDKCommonParam {
    localId: string; // 图片的localID
    success(res: { localData: string; errMsg: string; }): void; // localData是图片的base64数据，可以用img标签显示
}

export interface IWxJsSDKDownloadImageParam extends IWxJsSDKCommonParam {
    serverId: string; // 需要下载的图片的服务器端ID，由uploadImage接口获得
    isShowProgressTips?: number; // 默认为1，显示进度提示
    success(res: { localId: string; errMsg: string; }): void; // 返回图片下载后的本地ID
}

export interface IWxJsSDKUploadImageParam extends IWxJsSDKCommonParam {
    localId: string; // 需要上传的图片的本地ID，由chooseImage接口获得
    isShowProgressTips?: number; // 默认为1，显示进度提示
    success?: (res: { serverId: string; errMsg: string; }) => void; // 返回图片的服务器端ID
}

export enum WxJsSDKChooseImageSizeType {
    original = 'original',
    compressed = 'compressed',
}

export enum WxJsSDKChooseImageSourceType {
    album = 'album',
    camera = 'camera',
}

export interface IWxJsSDKChooseImageParam extends IWxJsSDKCommonParam {
    count?: number; // 默认9
    sizeType?: WxJsSDKChooseImageSizeType[]; // 可以指定是原图还是压缩图，默认二者都有
    sourceType?: WxJsSDKChooseImageSourceType[]; // 可以指定来源是相册还是相机，默认二者都有
    success(res: { localIds: string[], errMsg: string; }): void; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
}
